package sun.scheduler.util.graph.algorithm.maxflow;

import sun.scheduler.util.graph.Edge;
import sun.scheduler.util.collections.Heap;

/**
 * Represents the {
 *
 * @see Node} data used by a push-relabel max flow algorithm.
 * @param <N> some generic inner data.
 * @author mfj
 */
public class Label
{
    /**
     * Precission used to compare values.
     */
    public final static double DEFAULT_PRECISION = 1e-5;
    /**
     * Precission used to compare {@code double} values.
     */
    public final double precision;
    /**
     * The height label of the node.
     */
    protected int height;
    /**
     * The difference between ingoing and outgoing flow
     */
    protected double excess;

     /**
     * Instantiates a new {@link Label} instance with the default precision for
     * {@code} double comparison.
     */
    public Label()
    {
        this(DEFAULT_PRECISION);
    }

    /**
     * Instantiates a new {@link Label} instance with a specified precision for
     * {@code} double comparison.
     * @param precision 
     */
    public Label(double precision)
    {
        this.precision = precision;
    }

    
    
    /**
     * Adds some value to this excess.
     *
     * @param val the value to add
     */
    protected void addExcsess(double val)
    {
        this.excess += val;
    }

    /**
     * Indicates if this node is still active.
     *
     * @return {@code excess > 0}
     */
    public boolean isActive()
    {
        return excess > precision;
    }

    public double getExcess()
    {
        return excess;
    }

    public int getHeight()
    {
        return height;
    }

    /**
     *
     * @return
     */
    @Override
    public String toString()
    {
        return "e:" + excess + "/ h:" + height;
    }

}